<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame"%>
  <head>
	<title>公共平台 </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!-- 样式文件的引入 -->
	<link href="${ctx}/commons/css/style.css" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/icon.css">
	<!-- jqueryUI JS文件的引入 -->
	<script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${ctx}/commons/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/commons/js/easyui-extends-validate.js"></script>
	<!-- jqueryUI国际化 -->
	<script type="text/javascript" src="${ctx}/commons/js/easyui-lang-zh_CN.js"></script>
	<!-- 开发使用的公用js方法 -->
	<script type="text/javascript" src="${ctx}/commons/js/common.js"></script>
	<!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
	<script type="text/javascript">var ctx = '${ctx}';var actionExt = "action";var i18n = new Object();</script>
	<script src="${ctx}/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
  </head>
  
  <body>
    <div class="easyui-layout" data-options="fit:true,border:false" >
		<div id="tab" class="easyui-tabs" data-options="fit:true,border:false" style="">
			<div title="中心受理项目" style="height: 100%;">
				<div data-options="region:'north',border:false" style="padding: 4px;height: 80px;overflow: hidden;">
					<div class="easyui-panel" data-options="fit:true,border:true" >
						<div  class="queryContent">
							<form name="searchProjectsForm" id="searchProjectsForm" method="post" action="" style="display: none; ">
								<table class="queryTable" >
									<tbody>
									<tr>
										<th >项目名称</th>
										<td width="10%">
											<input id="name" class="easyui-validatebox" type="text" name="name"  maxlength="50" style="width:120px;height: 15px;"/>
										</td>
										<th>项目编号</th>
										<td>
											<input id="code" class="easyui-validatebox" type="text" name="code"  maxlength="20" style="width:120px;height: 15px;"/>
										</td>
										<th >项目类型</th>
										<td width="10%">
											<select class="easyui-combobox" name="catagoryId" style="width:120px;;height: 25px;" data-options="">
												<option value="">--请选择--</option>
												<c:forEach items="${projectTypeList}" var="type">
													<option value="${type.id}">${type.name}</option>
												</c:forEach>
											</select>
										</td>
										<th  >状态</th>
										<td>
											<select id="status" style="width:120px;height: 25px;" class="easyui-combobox" name="status">
												<option value="">--请选择--</option>
												<c:forEach items="${frame:dictChildrenByRole('proj_status','system')}" var="type">
													<option value="${type.value}">${type.name}</option>
												</c:forEach>
											</select>
										</td>
									</tr>
									<tr>
										<th>创建时间</th>
										<td align="right" colspan="5">
											<input id="startTime" class="easyui-datebox" type="text" name="startTime"  data-options="validType:['dateTimeLessCompare[\'stopTime\']']" maxlength="20" style="width:120px;height: 25px;"/>-<input id="stopTime" class="easyui-datebox" type="text"  data-options="validType:['dateTimeMoreCompare[\'startTime\']']" name="stopTime" maxlength="20" style="width:120px;height: 25px;"/>
										</td>
										<!--
                                        <th>预算金额(元)</th>
                                        <td>
                                             <input id="startMoney" class="easyui-validatebox" type="text" name="startMoney"  data-options="validType:['rangeLessCompare[\'endMoney\']']" maxlength="20" style="width:120px"/>-<input id="endMoney" class="easyui-validatebox" type="text"  data-options="validType:['rangeMoreCompare[\'startMoney\']']" name="endMoney" maxlength="20" style="width:120px"/>
                                        </td>
                                        -->
										<th></th>
										<td align="right" colspan="3">
											<a href="javascript:void(0);" class="easyui-linkbutton" id="searchProjects" iconcls="icon-search" plain="true">查询</a>
											<a href="javascript:void(0);" class="easyui-linkbutton" id="resetsearchProjects" iconcls="icon-reset" plain="true">清空</a>
										</td>
									</tr>
									</tbody>
								</table>
							</form>
						</div>
					</div>
				</div>
				<div data-options="region:'center',border:false" style="padding: 4px;"id="listProjectsTableDiv">
					<table id="listProjectsTable" class="easyui-datagrid"
						   data-options="singleSelect:false,toolbar:'#goodstb',method:'post',rownumbers:true,fit:true,fitColumns:true,border:true,
					pagination:true,multiSort:true,remoteSort:true,striped:true,onLoadSuccess:function(data){$('#'+projectsParamObj.searchID).attr('disabled',false);},
					url:'${ctx}/business/projectmanage/list?roleId=system'"}>
						<thead>
						<tr>
							<th data-options="field:'name',width:160,title:'项目名称',sortable:true" align="center"></th>
							<th data-options="field:'code',width:80,title:'项目编号',sortable:true" align="center"></th>
							<th data-options="field:'catagoryName',width:80,title:'项目类型',sortable:true" align="center"></th>
							<th data-options="field:'buyName',width:100,title:'采购人',sortable:true" align="center"></th>
							<th data-options="field:'createTime',width:100,title:'创建时间',sortable:true" align="center"></th>
							<th data-options="field:'statusName',width:80,title:'状态',sortable:true" align="center"></th>
							<th data-options="field:'operation',width:150,title:'操作'" align="center"></th>
						</tr>
						</thead>
					</table>
					<div id="goodstb" style="display: none;">
						<div>
							<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-export" onclick="exportProjects()"  plain="true">导出到未开标项目</a>
						</div>
					</div>
					<!----------------------- wei start --------------------->
					<!--导出Excel -->
					<script type="text/javascript">
						/**
						 *导出项目
						 */
						function exportProjects(){
							top.$('#firstLevelDialog').dialog({
								title:"导出项目",
								iconCls:'icon-view',
								width: 1000,
								height: 630,
								closed: false,
								inline : true,
								cache: false,
								href: "${ctx}/business/report/assignProjectReport?auditable=true",
								modal: true,
								extractor : function(data){
									if($.trim(data) == "unLogin"){
										var msn = ''||i18n[''];
										msn = msn||i18n[data];
										if(msn != undefined){
											top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
											return '';
										}
									}
									return data;
								},
								buttons : [{
									text:"取消",
									iconCls:'icon-cancel',
									handler:function(){
										top.$('#firstLevelDialog').dialog('close');
									}}]
							});
							top.$('#firstLevelDialog').dialog("center");
						}

					</script>
					<!----------------------- wei end --------------------->
				</div>
			</div>
			<div title="采购人发起项目" style="height: 100%;">
				<div data-options="region:'north',border:false" style="padding: 4px;height: 80px;overflow: hidden;">
					<div class="easyui-panel" data-options="fit:true,border:true" >
						<div  class="queryContent">
							<form name="searchNBProjectsForm" id="searchNBProjectsForm" method="post" action="" style="display: none; ">
								<table class="queryTable" >
									<tbody>
									<tr>
										<th >项目名称</th>
										<td width="10%">
											<input id="name" class="easyui-validatebox" type="text" name="name"  maxlength="50" style="width:120px;height: 15px;"/>
										</td>
										<th>项目编号</th>
										<td>
											<input id="code" class="easyui-validatebox" type="text" name="code"  maxlength="20" style="width:120px;height: 15px;"/>
										</td>
										<th >项目类型</th>
										<td width="10%">
											<select class="easyui-combobox" name="catagoryId" style="width:120px;;height: 25px;" data-options="">
												<option value="">--请选择--</option>
												<c:forEach items="${projectTypeList}" var="type">
													<option value="${type.id}">${type.name}</option>
												</c:forEach>
											</select>
										</td>
										<th  >状态</th>
										<td>
											<select id="status" style="width:120px;height: 25px;" class="easyui-combobox" name="status">
												<option value="">--请选择--</option>
												<c:forEach items="${frame:dictChildrenByRole('proj_status','system')}" var="type">
													<option value="${type.value}">${type.name}</option>
												</c:forEach>
											</select>
										</td>
									</tr>
									<tr>
										<th>创建时间</th>
										<td align="right" colspan="5">
											<input id="startTime" class="easyui-datebox" type="text" name="startTime"  data-options="validType:['dateTimeLessCompare[\'stopTime\']']" maxlength="20" style="width:120px;height: 25px;"/>-<input id="stopTime" class="easyui-datebox" type="text"  data-options="validType:['dateTimeMoreCompare[\'startTime\']']" name="stopTime" maxlength="20" style="width:120px;height: 25px;"/>
										</td>
										<!--
                                        <th>预算金额(元)</th>
                                        <td>
                                             <input id="startMoney" class="easyui-validatebox" type="text" name="startMoney"  data-options="validType:['rangeLessCompare[\'endMoney\']']" maxlength="20" style="width:120px"/>-<input id="endMoney" class="easyui-validatebox" type="text"  data-options="validType:['rangeMoreCompare[\'startMoney\']']" name="endMoney" maxlength="20" style="width:120px"/>
                                        </td>
                                        -->
										<th></th>
										<td align="right" colspan="3">
											<a href="javascript:void(0);" class="easyui-linkbutton" id="searchNBProjects" iconcls="icon-search" plain="true">查询</a>
											<a href="javascript:void(0);" class="easyui-linkbutton" id="resetsearchNBProjects" iconcls="icon-reset" plain="true">清空</a>
										</td>
									</tr>
									</tbody>
								</table>
							</form>
						</div>
					</div>
				</div>
				<div data-options="region:'center',border:false" style="padding: 4px;" id="listNBProjectsTableDiv">
					<table id="listNBProjectsTable" class="easyui-datagrid"
						   data-options="singleSelect:false,toolbar:'#nbPtb',method:'post',rownumbers:true,fit:true,fitColumns:true,border:true,
						pagination:true,multiSort:true,remoteSort:true,striped:true,onLoadSuccess:function(data){$('#'+projectsParamObj.searchID).attr('disabled',false);},
						url:'${ctx}/business/projectNb/list?roleId=system'"}>
						<thead>
						<tr>
							<th data-options="field:'name',width:170,title:'项目名称',sortable:true" align="center"></th>
							<th data-options="field:'code',width:90,title:'项目编号',sortable:true" align="center"></th>
							<th data-options="field:'catagoryName',width:80,title:'项目类型',sortable:true" align="center"></th>
							<th data-options="field:'buyName',width:120,title:'采购人',sortable:true" align="center"></th>
							<th data-options="field:'manageName',width:100,title:'项目负责人',sortable:true" align="center"></th>
							<th data-options="field:'createTime',width:100,title:'创建时间',sortable:true" align="center"></th>
							<th data-options="field:'bidStartTime',width:80,title:'开标时间 ',sortable:true" align="center"></th>
							<th data-options="field:'statusName',width:80,title:'状态',sortable:true" align="center"></th>
							<th data-options="field:'operation',width:160,title:'操作'" align="center"></th>
						</tr>
						</thead>
					</table>
					<div id="nbPtb" style="display: none;">
						<div>
							<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-export" onclick="exportNbProjects()"  plain="true">导出到未开标项目</a>
						</div>
					</div>
					<!----------------------- wei start --------------------->
					<!--导出Excel -->
					<script type="text/javascript">
						/**
						 *导出项目
						 */
						function exportNbProjects(){
							top.$('#firstLevelDialog').dialog({
								title:"导出项目",
								iconCls:'icon-view',
								width: 1000,
								height: 630,
								closed: false,
								inline : true,
								cache: false,
								href: "${ctx}/business/report/assignProjectReport?auditable=false",
								modal: true,
								extractor : function(data){
									if($.trim(data) == "unLogin"){
										var msn = ''||i18n[''];
										msn = msn||i18n[data];
										if(msn != undefined){
											top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
											return '';
										}
									}
									return data;
								},
								buttons : [{
									text:"取消",
									iconCls:'icon-cancel',
									handler:function(){
										top.$('#firstLevelDialog').dialog('close');
									}}]
							});
							top.$('#firstLevelDialog').dialog("center");
						}

					</script>
					<!----------------------- wei end --------------------->
				</div>
			</div>
		</div>
	</div>
</body>
	<script type="text/javascript">
		//初始化表格对应的js对象
		var projectsParamObj;
		$(function() {
			var height=$(window).height();

			$("#listProjectsTableDiv").css("height",height-150);
			$("#listNBProjectsTableDiv").css("height",height-150);

			//初始化表格对象数据
			projectsParamObj = new initParams(
					{
						paramObjName : 'projectsParamObj',//表格对应的实体对象名称，好区分多个表格情况下的对象
						tableId:'listProjectsTable',
						addDataFormId:'addProjectsDataForm',
						showDialogId:'firstLevelDialog',
						searchID:'searchProjects',
						resetSearchID:'resetsearchProjects',
						searchFormID:'searchProjectsForm',
						updateUrl:"${ctx}/business/projectmanage/input?projectId=",
						deleteUrl:'${ctx}/business/projectmanage/remove',
						addDialogWidth:800,
						addDialogHeight:720,
						ctx:'${ctx}',
						addDialogTitle:'采购项目信息'
					});
			//初始化查询
			init(projectsParamObj);


			//初始化表格对象数据"searchNBProjectsForm"
			NBprojectsParamObj = new initParams(
					{
						paramObjName : 'NBprojectsParamObj',//表格对应的实体对象名称，好区分多个表格情况下的对象
						tableId:'listNBProjectsTable',
						addDataFormId:'addProjectsDataForm',
						showDialogId:'firstLevelDialog',
						searchID:'searchNBProjects',
						resetSearchID:'resetsearchNBProjects',
						searchFormID:'searchNBProjectsForm',
						updateUrl:"${ctx}/business/projectmanage/input?projectId=",
						deleteUrl:'${ctx}/business/projectmanage/remove',
						addDialogWidth:700,
						addDialogHeight:520,
						ctx:'${ctx}',
						addDialogTitle:'采购项目信息'
					});

			//tab的选择事件
			$('#tab').tabs({
				border:false,
				onSelect:function(title,index){
					//alert(title+' is selected'+index);
					if(index==0){//评标项目
						//初始化查询
						init(projectsParamObj);
					}else{//不评标项目
						//初始化查询
						init(NBprojectsParamObj);
					}
				}
			});
		});
		
		/**
		 * 操作按钮处理
		 * @param {Object} value
		 * @param {Object} row
		 * @param {Object} index
		 */
		function getOptionsBtn(value, row, index){
			var btnsHtml = "<span class='optionBtnsArea'>"; 
			var assignHtml = '<a href="javascript:void(0)" onclick="assign(\'' + row.id + '\')" class="">分配</a>&nbsp;';
			var infoViewHtml = '<a href="javascript:void(0)" onclick="getProjectDetail(\'' + row.id + '\')" class="">详情</a>&nbsp;';
			  
			btnsHtml+=assignHtml;  
			btnsHtml+=infoViewHtml;  
			
			return btnsHtml +　"</span>";
		}


		 /**
		 *提交
		 **/
		 function doSubmit(id){
			 top.$.messager.confirm('提示',"您确认要提交吗？",function(result){
				 if(result){
					 $.ajax({
							type: "post",
							url:  "${ctx}/business/projectmanage/doSubmit",
							data:'projectId=' + id,
							success: function(data,res){
								var result = $.trim(res.responseText);
								if(result == "unLogin"){
									var msn = ''||i18n[''];
									msn = msn||i18n[result];
									if(msn != undefined){
										top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
										return ;
									}
								}
								top.$.messager.alert("提示",'提交成功','info',function(){
									$('#listProjectsTable').datagrid('reload');
								});
								
							},
							error: function(res){
								$.messager.alert('提示',i18n.requestError,'error');
							}
						});
				 }
			 });
			 return ;
		 }
		 

		 
		 /**
		 * 打开添加数据的页面的对话框(添加，修改)
		 * @param {Object} paramObj ： 对应的列表对象
		 * @param {Object} id ： 数据记录的ID
		 * @param {Object} successcallback ：添加数据成功后的回调函数
		 * @param {Object} failurecallback ： 添加数据失败后的回调函数  
		 */
		function openDataDialog(paramObj,id,successcallback,failurecallback){
			if(id == undefined){
				id='';
			}
			var sign = false;
			top.$('#'+paramObj.showDialogId).dialog({    
			    title:paramObj.addDialogTitle,   
			    iconCls:'icon-view',
			    width: paramObj.addDialogWidth,    
			    height: paramObj.addDialogHeight,    
			    closed: false,    
			    inline : true,
			    cache: false,    
			    href: paramObj.updateUrl+id,    
			    modal: true,
				extractor : function(data){
					if($.trim(data) == "unLogin"){
						var msn = ''||i18n[''];
						msn = msn||i18n[data];
						if(msn != undefined){
							$.messager.alert('提示',msn,'info',function(){top.location=paramObj.ctx+'/manage';});
							return '';
						}
					}
					return data;
				},
			    buttons : [{text:'提交',
			    		id:'commitEntityBt',
						iconCls:'icon-ok',
						handler:function(){
			    			submitEntity(paramObj,'saveEntityBt',1);
						}//增加保存按钮
					},{text:'保存',
			    		id:'addEntityBt',
						iconCls:'icon-save',
						handler:function(){
						    saveEntity(paramObj,'addEntityBt',0);
						}
					},{
						text:paramObj.cancelButton,//取消
						iconCls:'icon-cancel',
						handler:function(){
							top.$('#'+paramObj.showDialogId).dialog('close');
						}}],
				onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
					if(top.$('#'+paramObj.showDialogId).find("object").length > 0){
						var fileQueue = top.window.document.getElementById("fileQueue");
						fileQueue.innerHTML = "";
						fileQueue.parentNode.removeChild(fileQueue);
					}
				}
			});
			top.$('#'+paramObj.showDialogId).dialog("center");
		}
		
		/**
		 *保存按钮操作
		 **/
		function saveEntity(paramObj,opBtId,commitType){
			//alert("保存操作");
			//保存项目
			$.ajax({
				type : "post",
				url : "${ctx}/business/projectmanage/save?r="+new Date().getTime(),
				data : top.$("#addProjectsDataForm").serialize(),
				dataType : "text",
				success : function(data){
					var result=eval("("+data+")");
					if(result == "success"){
						top.$(".upload").uploadify('destroy');//销毁文件上传对象....
							top.$.messager.alert("提示",'保存成功','info',function(){
								$('#listProjectsTable').datagrid('reload');
								top.$('#firstLevelDialog').dialog('close');
							});
					}
					else{
						top.$.messager.alert("提示",'保存失败!');
					}
				},
				error : function(data){
					alert(2);
				}
			});
		}

		/**
		*提交按钮操作
		*/
		function submitEntity(paramObj,opBtId,commitType){
			//alert("提交按钮操作");
			if(top.$('#'+paramObj.addDataFormId).form('validate')){//表单校验是否通过
				$.ajax({
					type : "post",
					url : "${ctx}/business/projectmanage/doSubmit?r="+new Date().getTime(),
					data : top.$("#addProjectsDataForm").serialize(),
					success : function(data){
						if(result == "success"){
							top.$(".upload").uploadify('destroy');//销毁文件上传对象....
							top.$.messager.alert("提示",'提交成功','info',function(){
								top.$('#firstLevelDialog').dialog('close');
								top.$('#listProjectsTable').datagrid('reload');
							});
						}
						else{
							top.$.messager.alert("提示",'提交失败!');
						}
					}
				});
			}
		}

		
		/**
		*项目详情
		*/
		function getProjectDetail(id){
			top.$('#firstLevelDialog').dialog({    
			    title:"详情",  
			    iconCls:'icon-view',
			    width: 1000,    
			    height: 580,    
			    closed: false,    
			    inline : true,
			    cache: false,    
			    href: '${ctx}/business/projectmanage/getProjectDetail?projectId='+ id+"&roleId=system",
			    modal: true,
				extractor : function(data){
					if($.trim(data) == "unLogin"){
						var msn = ''||i18n[''];
						msn = msn||i18n[data];
						if(msn != undefined){
							top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
							return '';
						}
					}
					return data;
				},
			    buttons : [{
						text:projectsParamObj.cancelButton,
						iconCls:'icon-cancel',
						handler:function(){
							top.$('#firstLevelDialog').dialog('close');
						}}]
			});
			top.$('#'+projectsParamObj.showDialogId).dialog("center");
		}


		 

		/**
		 * 项目分配
		 */
		function assign(id){
			top.$('#firstLevelDialog').dialog({    
			    title:"项目分配",  
			    iconCls:'icon-view',
			    width: 500,    
			    height: 200,    
			    closed: false,    
			    inline : true,
			    cache: false,    
			    href: '${ctx}/business/projectmanage/assign/alertManagement?projectId='+ id,
			    modal: true,
				extractor : function(data){
					if($.trim(data) == "unLogin"){
						var msn = ''||i18n[''];
						msn = msn||i18n[data];
						if(msn != undefined){
							top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/user-login-sys-new/loginPwd';});
							return '';
						}
					}
					return data;
				},
			    buttons : [{text:'提交',
						iconCls:'icon-ok',  
						id:'commitEntityBt',
						handler:function(){
							top.$('#commitEntityBt').linkbutton('disable');
							if(top.$('#addOkOrCancelDataForm').form("validate")){
								$.ajax({
													type: "POST",
													timeout:2000,
													url:  top.$('#addOkOrCancelDataForm').attr("action"),
													data: top.$('#addOkOrCancelDataForm').serialize(),
													success: function(data,res){
														if(data != 'saveSuccess'){
															top.$.messager.alert('提示',"分配失败！",'error');
															$('#listProjectsTable').datagrid('reload');
															$('#listNBProjectsTable').datagrid('reload');
															top.$('#firstLevelDialog').dialog('close');
														} 
														else {
															top.$.messager.alert("提示",'分配成功','info',function(){ 
																$('#listProjectsTable').datagrid('reload');
																$('#listNBProjectsTable').datagrid('reload');
																top.$('#firstLevelDialog').dialog('close');
															});
															
														}
													},
													error: function(res){
														
													}
												});
						}
						}},{
						text:projectsParamObj.cancelButton,
						iconCls:'icon-cancel',
						handler:function(){
						
							top.$('#firstLevelDialog').dialog('close');
						}
						}]
			});
			top.$('#'+projectsParamObj.showDialogId).dialog("center");
		}
	 	//===============================================================
		
						
</script>